//
//  TextFileDemo.swift
//  firstProject
//
//  Created by 张彦辉 on 2017/5/3.
//  Copyright © 2017年 张彦辉. All rights reserved.
//

import UIKit

class TextFileDemo: UIViewController {
    let textFile:UITextField = UITextField(frame: CGRect(x: 20, y: 100, width: 280, height: 40))
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.white
        //设置输入框风格
        textFile.borderStyle = UITextBorderStyle.line
        textFile.borderStyle = UITextBorderStyle.bezel
        //设置输入框的提示文字
        textFile.placeholder = "请输入文字"
        //设置输入的文字颜色
        textFile.textColor = UIColor.red
        //设置输入的字体 斜体
        textFile.font = UIFont.italicSystemFont(ofSize: 16)
        //设置输入的文字对齐方式
        textFile.textAlignment = NSTextAlignment.center
        //是否每次进入编辑装态时都清空输入框中的文字
        textFile.clearsOnBeginEditing = true
        //设置字体自适应
        textFile.adjustsFontSizeToFitWidth = true
        //设置输入框不可用
        //textFile.enabled = false
        //设置输入框的左右试图
        let leftView = UIView(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
        let rightView = UIView(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
        leftView.backgroundColor = UIColor.red
        rightView.backgroundColor = UIColor.green
        textFile.leftView = leftView
        textFile.leftViewMode = UITextFieldViewMode.always
        //textFile.rightView = rightView
        //textFile.rightViewMode = UITextFieldViewMode.Always
        let board:UIView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 50))
        board.backgroundColor = UIColor.gray
        //设置弹出的交互键盘
        //textFile.inputView = board
        //设置付键盘
        textFile.inputAccessoryView = board
        //设置输入框的背景颜色
        //textFile.backgroundColor = UIColor.blueColor()
        textFile.clearButtonMode = UITextFieldViewMode.always
        self.view.addSubview(textFile)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        textFile.resignFirstResponder()
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
